<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>课程列表</title>
<script type="text/javascript" src="../boot.js"></script>
<script>
var tbgrid=null;
function parsePage(){

$('#toolbar').toolbar({
	items: [{
				text : '新增讲师',
				iconCls : 'icon-add',
				handler : function() {
					add();
				}
			}, '-', {
				text : '删除',
				iconCls:'icon-del',
				handler : function() {
					var node = tbgrid.datagrid('getSelections');
					var ids=[];
					$.each(node,function(index,val){
						ids.push(val.id);
					});
					del(ids);
				}
			}] 
});

toolSearch({
	items:[{text:'讲师姓名',name:'key1'}],
	collapsible:false,
	callback:function(key,name){
			if(key==""){
				showInfo('请输入关键字');
				return;
			}
		showInfo(key);
	}
});

tbgrid = $('#tbList').datagrid({
			data:{"total":1,"rows":[{'id':1,'col1':'张三疯','col2':'深圳著名电子商务讲师','col3':'0755-862312345','col4':'13800138000','col5':'13800138000@qq.com','col6':'123456','col7':'123456@qq.com','col8':1}]},
			singleSelect:false,
			frozenColumns : [[{
				title : 'id',
				field:'id',
				checkbox : true
			}]],
		    columns:[[
					{
					title:'讲师姓名',
					field:'col1',
					width:100,
					align:'left',
					sortable:true
				    },
					{
					title:'讲师简介',
					field:'col2',
					width:200
					},{
					title:'联系电话',
					field:'col3',
					width:100
					},{
					title:'手机号码',
					field:'col4',
					width:100
					},{
					title:'电子邮箱',
					field:'col5',
					width:100
					},{
					title:'QQ',
					field:'col6',
					width:150
					},{
					title:'MSN',
					field:'col7',
					width:100
					},{
					title:'状态',
					field:'col8',
					width:100,
					formatter:function(value,rec,index){
						return value==0?'未审核':'已审核';
					}
					},{
					title:'操作',
					field:'opt',
					width:100,
					formatter:function(value,rec,index){
						var str='<a href="javascript:;" class="jsEdit">编辑</a> | <a data-id='+rec.id+' href="javascript:;" class="jsDel">删除</a>';
						return str;
					}
					}
		]],
		onLoadSuccess:function(){
			//编辑
			$('.jsEdit').click(function(){
				var _this=$(this);
				return false;
			});
			
			//删除
			$('.jsDel').click(function(){
				var id=$(this).attr('data-id');
				del(id);
				return false;
			});
		
		}

	});

}


function add(){
	ygDialog({
		title:'添加讲师',
		target:$('#myFormPanel'),
		width:680,
		height:500,
		 buttons:[{
			text:'确认',
			handler:function(dialog){
				save(dialog);
			}
		},{
				text:'取消',
				handler:function(dialog){
					dialog.close();
				}
		}]
	});
}


function del(id){
	if(id.length<=0){
		showError('请选择需要删除的项目！');
		return;
	}
	showConfirm('确认删除吗？',function(){					 
				showSuc('删除成功！'+id);
				tbgrid.datagrid('deleteRow',0);
				$('#tbList').datagrid('reload');
				  
	});
}

function save(dialog){
	var myform=$('#myForm');
	myform.form({
		url:'form3_proc.php',
		onSubmit:function(){
			return $(this).form('validate');
		},
		success:function(data){
			showSuc('操作成功！');
			dialog.close();
		}
	});
	myform.submit();
}
</script>
</head>

<body class="easyui-layout">
<div data-options="region:'north',border:false" class="toolbar-region">
    <div id="toolbar">
    </div>
</div>
<div data-options="region:'center',border:false">
    <table id="tbList">
    </table>
</div>
<!--subLayout end-->


<div id="myFormPanel" class="easyui-dialog" data-options="closed:true">
    <div class="pd10">
       <form id="myForm" method="post" novalidate>
        <table class="form-tb">
            <tbody>
                <tr>
                    <th style="width:100px;"><em class="cred">*</em>讲师姓名：</th>
                    <td><input type="text" class="ipt easyui-validatebox" data-options="required:true,missingMessage:'讲师姓名不能为空！'" /></td>
                    <th><em class="cred">*</em> 手机号码：</th>
                    <td><input type="text" class="ipt easyui-validatebox" validType="mobile" data-options="required:true,missingMessage:'手机号码不能为空！',tipPosition:'bottom'" /></td>
                </tr>
                <tr>
                    <th>固定电话：</th>
                    <td><input type="text" class="ipt" /></td>
                     <th><em class="cred">*</em> 电子邮箱：</th>
                    <td><input type="text" class="ipt easyui-validatebox" validType="email" data-options="required:true,missingMessage:'电子邮箱不能为空！',tipPosition:'bottom'" /></td>
                </tr>
                <tr>
                    <th>QQ：</th>
                    <td><input type="text" class="ipt" /></td>
                    <th>MSN：</th>
                    <td><input type="text" class="ipt" /></td>
                </tr>
                <tr>
                    <th>旺旺：</th>
                    <td><input type="text" class="ipt" /></td>
                    <th><em class="cred">*</em> 个人照片：</th>
                    <td><input class="ipt easyui-inputfile "  type="file"  /></td>
                </tr>
                <tr>
                    <th  class="vtop"><em class="cred">*</em> 讲师介绍：</th>
                    <td colspan="3"><textarea style="visibility:hidden;width:480px;height:250px;" class="easyui-editor" ></textarea></td>
                </tr>
            </tbody>
        </table>
    </form>
    </div>
</div>

</body>
</html>
